package view
{
	import common.HelloWorldConstants;
	
	import flash.events.MouseEvent;
	import flash.utils.getQualifiedClassName;
	
	import org.osflash.thunderbolt.Logger;
	import org.puremvc.as3.multicore.utilities.fabrication.patterns.mediator.FlexMediator;
	
	import view.components.HelloWorldApplicationBar;

	public class HelloWorldApplicationBarMediator extends FlexMediator
	{
		public static const NAME:String = getQualifiedClassName(HelloWorldApplicationBarMediator);
		
		public function HelloWorldApplicationBarMediator(viewComponent:Object)
		{
			super(NAME, viewComponent);
		}
		
		override public function onRegister():void
		{
			registerEventListeners();
		}
		
		
		private function registerEventListeners():void
		{
			app.loadModule.addEventListener(MouseEvent.CLICK, loadModuleClickHandler);	
		}
		
		private function loadModuleClickHandler(e:MouseEvent):void
		{
			Logger.info(NAME+ " : loadModuleClickHandler()");
			//sendNotification(HelloWorldConstants.LOAD_MODULE_COMMAND);
			sendNotification(HelloWorldConstants.ADD_MODULE);
		}
		
		public function get app():HelloWorldApplicationBar
		{
			return viewComponent as HelloWorldApplicationBar;
		}
	}
}